var bcrypt = require('bcryptjs')

// 生成hash密码
const encryption = (password) => {
    // 生成随机数
    let salt = bcrypt.genSaltSync(10)

    // 生成hash密码
    let hash = bcrypt.hashSync(password, salt)

    return hash
}
// 解密方法

const verifcation = async (password, hash) => {
    // 判断解密
    let valif = await bcrypt.compare(password, hash)
    return valif
}
module.exports = { encryption, verifcation }